From: Keir Fraser Date: Mon, 19 Oct 2009 09:49:23 +0000 (+0100) Subject: gdbsx: malloc extra bye for null char X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13208 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=70829c3d48270689fdea6ec8808a232d88483d65;p=xen.git gdbsx: malloc extra bye for null char Signed-off-by: Mukesh Rathor --- diff --git a/tools/debugger/gdbsx/gx/gx_comm.c b/tools/debugger/gdbsx/gx/gx_comm.c index f991952239..156a9f5f55 100644 --- a/tools/debugger/gdbsx/gx/gx_comm.c +++ b/tools/debugger/gdbsx/gx/gx_comm.c @@ -299,6 +299,7 @@ gx_putpkt (char *buf) if (write(remote_fd, buf2, p - buf2) != p - buf2) { perror("putpkt(write)"); + free(buf2); return -1; } if (gx_remote_dbg) diff --git a/tools/debugger/gdbsx/gx/gx_main.c b/tools/debugger/gdbsx/gx/gx_main.c index f20f6ef0d7..07923af973 100644 --- a/tools/debugger/gdbsx/gx/gx_main.c +++ b/tools/debugger/gdbsx/gx/gx_main.c @@ -201,7 +201,7 @@ process_m_request(char *remote_buf) gx_decode_m_packet(&remote_buf[1], &addr, &len); - if ((xbuf=malloc(len)) == NULL) { + if ((xbuf=malloc(len+1)) == NULL) { gx_reply_error(remote_buf); return; } @@ -227,7 +227,7 @@ process_M_request(char *remote_buf) data_strtp = gx_decode_M_packet(&remote_buf[1], &addr, &len); - if ((xbuf=malloc(len)) == NULL) { + if ((xbuf=malloc(len+1)) == NULL) { gx_reply_error(remote_buf); return; }